package service

import (
	"context"
	"video-srv/basic/config"
	__ "video-srv/basic/proto/rpc"
	"video-srv/handler/model"
)

func (s *VideoServer) AddFavorite(_ context.Context, in *__.AddFavoriteReq) (*__.AddFavoriteResp, error) {
	favorite := model.Favorite{
		UserId:  int(in.UserId),
		VideoId: int(in.VideoId),
	}
	err := favorite.AddFavorite(config.DB)
	if err != nil {
		return nil, err
	}
	return &__.AddFavoriteResp{
		FavoriteId: int64(favorite.ID),
	}, nil
}
